<?php
    include_once 'include.php';
    $username =  mysql_real_escape_string($_POST['username']);
    $prePassword  = mysql_real_escape_string($_POST['password']);
    $password = md5($prePassword);
    $result = $db->get_row("Select * from Users WHERE username = '".$username."' && password ='".$password."'");

    if($result != null)
    {
        $_SESSION['id'] = $result->id;
        $_SESSION['admin'] = $result->admin;
        $_SESSION['name'] = $result->username;
        //userLogged($result->id);
        header("Location:index.php");
    }
    else
    {
        echo "Login Failed";
    }
?>